package com.contact.util.util.validation;

/**
 * Validates the the "forbidden" property is null
 */
public class ForbiddenPropertyValidator implements PropertyValidator {

    private final transient String property;

    public ForbiddenPropertyValidator(String property) {
        this.property = property;
    }

    @Override
    public String getProperty() {
        return property;
    }

    @Override
    public ValidationError validate(Object value) {
        if (value != null) {
            return new ValidationError(String.format("Forbidden property '%s' must be null.", property));
        }

        return null;
    }
}
